import userUtil from '../../js/util/user'
let localData = require('../../lib/localData');
export default {
    name: "login",
    data() {
        return {
            user:{
                phone:"",
                pwd:""
            },
            /*轮播图*/
            carouselList:[],
        }
    },
    created : function() {
        this.set("user_login_token","");
    },
    mounted : function() {
        this.$(".layui-layer-dialog .layui-layer-content").css("font-size","1.9rem")
        this.$(".layui-layer-title").css("font-size","2rem")
    },
    methods: {
        loginFn:function () {
            const param= this.user;
            this.user.userName=$.trim(this.user.userName);
            this.user.pwd=$.trim(this.user.pwd);
            if(!this.user.phone){
                this.layer.alert("账号不能为空");
                return;
            }
            if(!this.user.pwd){
                this.layer.alert("密码不能为空");
                return;
            }
            this.$post(url.userLogin, param)
                .then((response) => {
                    userUtil.setToken(response.data);
                    localData.sets("loginType","mobile");
                    this.$router.push({path: '/mobileLayout/mobileHome'});
                }).catch(err => {
                console.log(err);
            })
        }
    }
}
